<?
class Contact extends genericClass {
	function checkBlackList(){
		//On recherche le groupe de la blacklist
		//On teste l'existence dans la blacklist
		$Bid = BLACKLIST;
		$Tab = $GLOBALS["Systeme"]->Modules["Newsletter"]->callData("Newsletter/GroupeEnvoi/".$Bid."/Contact/Email=".$this->Email,"",0,1,"","","COUNT(DISTINCT(m.Id))");
		if ($Tab[0]["COUNT(DISTINCT(m.Id))"]>=1){
			return false;
		}
		return true;
	}
	function Save() {
		//On recherche le groupe parent
		if ($this->Id){	
			$Gid = $this->getParents('GroupeEnvoi');
			$Gid = $Gid[0]->Id;
		}else{
			$Gid = $this->getParentsFromType('GroupeEnvoi');
			$Gid = $Gid[0]["Id"];
		}
		if ($Gid=="")return false;
		$Bid = BLACKLIST;
		if ($Gid==$Bid){
			$Tab = $GLOBALS["Systeme"]->Modules["Newsletter"]->callData("Newsletter/GroupeEnvoi/".$Bid."/Contact/Email=".$this->Email,"",0,1,"","","COUNT(DISTINCT(m.Id))");
			if ($Tab[0]["COUNT(DISTINCT(m.Id))"]==0){
				genericClass::Save();
				return false;
			}else return false;
		}
		if ($this->checkBlackList())genericClass::Save();
		else{
			$this->AddError("Email présent dans la blacklist.");
			return false;
		}
	}
}
?>